package cn.gudian.cms.News
/** *
 * 栏目域
 */
class ArcType {
  static hasMany = [childrens: ArcType];
  ArcType parent;//父级栏目ID，如果为根级栏目默认为空
  String mode; //模型
  String name;//栏目名称
  String path;//栏目路径
  double orderNum;//排序
  String tempindex;//封面模板
  String templist;//列表模板
  String temparticle;//内容模板
  String description;//栏目描述
  String keywords;//栏目关键词
  boolean ishidden;//是否隐藏栏目（0：显示）
  static mapping = {
     sort id:"desc"
    cache true     //开启缓存
    description type: 'text'
    keywords type: 'text'
    parent: [column: 'parent_Id', lazy: "true", cascade: "none"]
    children joinTable: [name: 'children', key: 'parent_Id', column: 'Id', lazy: "true", inverse: "false", cascade: "none"]
    id index: 'ModeAndModeID_Idx'
    mode index: 'Mode_Idx,ModeAndModeID_Idx'
    parent index: "Parent_Idx"

  }
  static constraints = {
    parent(nullable: true)
     mode(inList: ["Article", "Product","Banner"])
    name(maxlength: 200, blank: false);//栏目名称
    path(maxlength: 200, blank: false, unique: true);
    orderNum();//排序
    tempindex(maxlength: 200);//封面模板
    templist(maxlength: 200);//列表模板
    temparticle(maxlength: 200);//内容模板
    description();//栏目描述
    keywords();//栏目关键词
    ishidden();//是否隐藏栏目（0：显示）
  }

  String toString() {
    "${this.name}"
  }

 static def modeStates = ["Article": "文章模块", "Product": "案例模块","Banner":"首页展示"];

  static String getsize(String mode) {
    def result = ""
      switch (mode) {
      case "Article":
        result = "w=97&h=64"
        break
      case "Product":
        result = "w=154&h=68"
        break
      default:
        result = "w=154&h=68"
    }
  }

  String modeStatesFormat() {
    return modeStates.get(mode)
  }
}
